package org.jsbd.boss.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IChannelApkConfigDAO;
import org.jsbd.boss.dao.IDaylimitDAO;
import org.jsbd.boss.dao.IMiguMusicConfigDao;
import org.jsbd.boss.dao.IMiguMusicDaylimitDAO;
import org.jsbd.boss.domian.DaylimitBean;
import org.jsbd.boss.domian.DaylimitBeanVO;
import org.jsbd.boss.domian.MiguMusicConfigBean;
import org.jsbd.boss.domian.MiguMusicDaylimitBean;
import org.jsbd.boss.domian.MiguMusicDaylimitVO;
import org.jsbd.boss.domian.channel.ChannelApkConfig;
import org.jsbd.boss.service.IDaylimitService;
import org.jsbd.boss.service.IMiguMusicDaylimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("miguMusicDaylimitService")
public class MiguMusicDaylimitServiceImpl implements IMiguMusicDaylimitService {
	
	@Resource
	private IMiguMusicDaylimitDAO miguMusicDaylimitDAO;
	@Resource
	private IMiguMusicConfigDao miguMusicConfigDao;
	
	/**
	 * 获取所有数据
	 */
	@Override
	public Map<String, Object> findDataWithPage(DataGridModel page, MiguMusicDaylimitVO mmdVO) {
		return miguMusicDaylimitDAO.findDataWithPage(page, mmdVO);
	}

	/**
	 * 新增
	 */
	@Override
	public void save(MiguMusicDaylimitBean mmdBean) {
		miguMusicDaylimitDAO.insert(mmdBean);
	}

	/**
	 * 查询单个实例
	 */
	@Override
	public MiguMusicDaylimitBean findDaylimit(Integer id) {
		return miguMusicDaylimitDAO.selectOne(id);
	}

	/**
	 * 修改
	 */
	@Override
	public void modifyDaylimit(MiguMusicDaylimitBean mmdBean) {
		miguMusicDaylimitDAO.updateDAO(mmdBean);
	}

	/**
	 * 删除
	 */
	@Override
	public void delete(Integer id) {
		miguMusicDaylimitDAO.delete(id);
	}

	/**
	 * 获取增量数据
	 */
	@Override
	public List<MiguMusicDaylimitBean> findDeltaData(int offset) {
		return miguMusicDaylimitDAO.selectDeltaData(offset);
	}
	
	/**
	 * 更新daylimit
	 */
	@Override
	@Transactional("transactionManagerCrack")
	public void updateDaylimit(List<MiguMusicConfigBean> configs, List<MiguMusicDaylimitBean> mmdBeans) {
		miguMusicConfigDao.updateDaylimit(configs);
		miguMusicDaylimitDAO.updateIsExecute(mmdBeans);
	}


	/**
	 * 验证是否存在mark
	 */
	@Override
	public MiguMusicConfigBean hasName(String name) {
		return miguMusicConfigDao.getByName(name);
	}

	@Override
	public boolean isRepeat(String mark) {
		MiguMusicDaylimitBean mmdBean = miguMusicDaylimitDAO.getByMark(mark);
		if (null == mmdBean) {
			return false;
		}
		return true;
	}

}
